package com.hmdp;

import io.reactivex.rxjava3.internal.util.LinkedArrayList;

import java.util.*;

/**
 * @author 杨帆
 * @version 1.0
 */
public class Solution {
    private static List<Integer>[] adj; // 邻接表
    private static boolean[] visited; // 访问标记数组
    private static int[] heights; // 水库高度数组
    private static int[] counts; // 统计结果数组

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); // 水库数量
        int m = sc.nextInt(); // 管道数量
        heights = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            heights[i] = sc.nextInt(); // 读入水库高度
        }
        adj = new List[n + 1];
        for (int i = 1; i <= n; i++) {
            adj[i] = new ArrayList<>();
        }
        for (int i = 0; i < m; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            adj[u].add(v);
            adj[v].add(u); // 无向图,需要添加双向边
        }

        counts = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            visited = new boolean[n + 1];
            dfs(i, i); // 从每个水库开始DFS
        }

        for (int i = 1; i <= n; i++) {
            System.out.print(counts[i] + " ");
        }
    }

    private static void dfs(int start, int curr) {
        visited[curr] = true;
        for (int next : adj[curr]) {
            if (!visited[next] && heights[next] < heights[start]) {
                counts[start]++;
                dfs(start, next);
            }
        }

       // Deque<Integer>stack = new LinkedList<>();
    }
}
